/**
 * Copyright (c) 2014 zhenrongbao.com, Inc. All Rights Reserved
 * @author: jiangshuguang
 * @Date  : 14-12-15
 * @Time  : 下午9:05
 * @brief :
 */
(function () {
    var Tip = require('wap_common:widget/ui/tip/tip.js').Tip,
        ShareTip = require('wap_common:widget/ui/sharetip/sharetip.js').ShareTip,
        Share = require('wap_common:widget/ui/share/share.js').Share,
        $page = $('.page-asset'),
        shareTip = new ShareTip(),
        shareData = P.data('share_data'),
        sendFriendTip = new Tip(),
        appMessageTitle,
        appMessageDescContent = '一元起投，保本保息！这么靠谱，还不快跟我一起加入！',
        timeLineTitle,
        share;


    if(shareData){
        if(shareData.type == "profit"){
            appMessageTitle = '我在真融宝裡已经赚了'+shareData.num+'元';
            timeLineTitle = '我在真融宝裡已经赚了'+shareData.num+'元。很靠谱，推荐给你！';
        }else if(shareData.type == "monthreturn"){
            appMessageTitle = '我一个月将在真融宝裡赚'+shareData.num+'元';
            timeLineTitle = '我一个月将在真融宝裡赚'+shareData.num+'元。很靠谱，推荐给你！';
        }else if(shareData.type == "rate"){
            appMessageTitle = '我在真融宝裡投资，年化利率14%';
            timeLineTitle = '我在真融宝裡投资，年化利率14%！快跟我一起加入吧';
        }
    }


    share = new Share({
        lineLink:location.protocol+'//'+location.host+'/share/sharetmp?sequence_id='+P.data('sequence_id'),
        appMessageTitle:appMessageTitle,
        appMessageDescContent:appMessageDescContent,
        timeLineTitle:timeLineTitle,
        onSendFriend:function(ret){
            shareTip.hide();
            sendFriendTip.show('' +
                '<div>亲，别这么小气</div>' +
                '<div>告诉你所有的朋友嘛</div>' +
                '<div>请分享到朋友圈获取抽奖机会</div>' +
                '');
        },
        onSendFriends:function(res){
            if(res.err_msg == "share_timeline:ok"){
                $.get('/share/couponshare',function(ret){
                    location.href="/share/lottery";
                },'json');
            }
        }
    });

    $page.find('.share-btn').click(function(){
        shareTip.showShare('分享获取抽奖机会');
    })
})();